package com.loop.unclelend.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.app_config.UncleConfigs
import com.loop.unclelend.utils.ImageUtil
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/27 11:51
 * @Annotation：贷款详情 - 账户列表
 */
class Adapter_Loan_Details_Account(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_account) {
    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.img_delete) //点击Item
    }
    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        var showName = model.optString("name","")
        if (showName.isEmpty() || showName == "null"){
            showName = "test"
        }
        helper.setText(R.id.txt_title,showName)
        helper.setText(R.id.txt_account,"+" + model.optString("account"))
        val imgLogo = helper.getImageView(R.id.img_logo)
        ImageUtil.instance!!.loadImageUrl(mContext,imgLogo,model.optString("logo"), R.mipmap.icon_holder)

        if (UncleConfigs.isFrench()){
            helper.setVisibility(R.id.img_delete, View.VISIBLE)
        } else {
            helper.setVisibility(R.id.img_delete, View.INVISIBLE)
        }
    }
}